package middware

import (
	"gateway/core"
	"log"
	"net/http"
)

func Recovery() core.MiddlewareFunc {
	return func(ctx *core.Context) bool {
		defer func() {
			if err := recover(); err != nil {
				log.Printf("Panic recovered: %v", err)
				ctx.JSON(http.StatusInternalServerError,
					map[string]string{"error": "Internal Server Error"})
			}
		}()
		return true
	}
}
